package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.DiseaseDao;
import com.aaa.ssm.entity.Department;
import com.aaa.ssm.entity.Disease;
import com.aaa.ssm.service.DiseaseService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DiseaseServiceImpl implements DiseaseService {
    @Resource
    private DiseaseDao diseaseDao;


    @Override
    public PageInfo queryByParam(Page<Disease> page) {
        //设值分页参数   startPage(int pageNum, int pageSize)  pageNum 第几页  pageSize 页面
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(diseaseDao.queryByParam(page.getData()));
    }
    @Override
    public Disease queryById(Integer diseaseId) {
        return diseaseDao.queryById(diseaseId);
    }

    @Override
    public int add(Disease disease) {
        return diseaseDao.add(disease);
    }

    @Override
    public int update(Disease disease) {
        return diseaseDao.update(disease);
    }

    @Override
    public int deleteById(Integer diseaseId) {
        return diseaseDao.deleteById(diseaseId);
    }
    @Override
    public PageInfo queryByPage(Page<Disease> page) {
        //设值分页参数   startPage(int pageNum, int pageSize)  pageNum 第几页  pageSize 页面
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(diseaseDao.queryByParam(page.getData()));
    }

    @Override
    public List<Disease> queryDisease(Integer departmentId) {
        return diseaseDao.queryDisease(departmentId);
    }

    @Override
    public List<Department> getAllDepartments() {
        return diseaseDao.getAllDepartments();
    }
}
